#! /bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto


${PRESTO_HOME} --catalog hive --server 192.168.88.80:8090 --execute "
insert into table edu_dwd.wf_dim_customer
select id,
       customer_relationship_id,
       create_date_time,
       update_date_time,
       deleted,
       name,
       creator,
       origin_type,
       origin_channel
from edu_ods.customer;

insert into table edu_dwd.wf_dim_customer_appeal
select id,
       customer_relationship_first_id,
       employee_id,
       employee_name,
       employee_department_id,
       employee_tdepart_id,
       appeal_status,
       create_date_time,
       update_date_time,
       deleted
from edu_ods.customer_appeal;

insert into table edu_dwd.wf_dim_customer_clue
select id,
    create_date_time,
    update_date_time,
    deleted,
    customer_id,
    customer_relationship_id,
    session_id,
    sid,
    status,
    platform,
    area,
    country,
    province,
    city,
    creator,
    itcast_school_id,
    itcast_school,
    itcast_subject_id,
    itcast_subject,
    origin_type,
    clue_state,
    is_repeat
from edu_ods.customer_clue;

insert into table edu_dwd.wf_dim_customer_relationship
select
    id,
    create_date_time,
    update_date_time,
    deleted,
    customer_id,
    first_id,
    origin_type,
    itcast_school_id,
    itcast_subject_id,
    creator,
    current_creator,
    creator_name,
    origin_channel,
    first_customer_clue_id,
    last_customer_clue_id
from edu_ods.customer_relationship;

insert into table edu_dwd.wf_dim_employee
select
    id,
    real_name,
    department_id,
    department_name,
    job_number,
    creator,
    create_date_time,
    update_date_time,
    deleted,
    scrm_department_id,
    leave_office,
    leave_office_time,
    reinstated_time,
    superior_leaders_id,
    tdepart_id
from edu_ods.employee;

insert into table edu_dwd.wf_dim_itcast_school
select
    id,
    name
from edu_ods.itcast_school;

insert into table edu_dwd.wf_dim_itcast_subject
select
    id,
    deleted,
    name
from edu_ods.itcast_subject;

insert into table edu_dwd.wf_dim_scrm_department
select
    id,
    name,
    parent_id,
    create_date_time,
    update_date_time,
    deleted
from edu_ods.scrm_department;

insert into table edu_dwd.wf_fact_customer_clue
select
    id,
    create_date_time,
    update_date_time,
    deleted,
    customer_id,
    customer_relationship_id,
    session_id,
    sid,
    status,
    platform,
    area,
    country,
    province,
    city,
    creator,
    itcast_school_id,
    itcast_school,
    itcast_subject_id,
    itcast_subject,
    origin_type,
    clue_state,
    is_repeat
from edu_ods.customer_clue;

insert into table edu_dwd.wf_fact_customer_relationship
select
    id,
    create_date_time,
    update_date_time,
    deleted,
    customer_id,
    first_id,
    origin_type,
    itcast_school_id,
    itcast_subject_id,
    creator,
    current_creator,
    creator_name,
    origin_channel,
    first_customer_clue_id,
    last_customer_clue_id
from edu_ods.customer_relationship;"